﻿namespace Jumpton.SFA.Server.Entity
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using Jumpton.Persistent;
    using System.Data;

    [System.SerializableAttribute()]
    [RelationMap("PRODUCTS", typeof(PRODUCTS), "a")]
    [Relation(RelationJoinType.Inner, typeof(PRODUCT_UOMS), "b", "a", "PRODUCT_ID", "ID")]
    public class PRODUCTVIEW : ObjectRow
    {

        public PRODUCTVIEW()
        {
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="dataRow">DataTable 中的一行数据</param>
        /// <param name="objectTable">存储当前对象的数据表格</param>
        public PRODUCTVIEW(System.Data.DataRow dataRow, ObjectTable parent) :
            base(dataRow, parent)
        {
        }

        [Key("ID", TableAlias = "a")]//主键,对应数据库中的列名
        public int ID
        {
            get { return (System.Int32)GetValue("ID"); }
            set { SetValue("ID", value); }
        }

        [Field("CODE", TableAlias = "a")]
        public string ProductCode
        {
            get
            {
                return (System.String)GetValue("ProductCode");
            }
            set
            {
                SetValue("ProductCode", value);
            }
        }

        [Field("INTERNAL_CODE", TableAlias = "a")]
        public string INTERNALCODE
        {
            get
            {
                return (System.String)GetValue("INTERNALCODE");
            }
            set
            {
                SetValue("INTERNALCODE", value);
            }
        }

        [Field("EAN_CODE", TableAlias = "a")]
        public decimal EANCODE
        {
            get
            {
                return (System.Decimal)GetValue("EANCODE");
            }
            set
            {
                SetValue("EANCODE", value);
            }
        }

        [Field("DUN_CODE", TableAlias = "a")]
        public string DUNCODE
        {
            get
            {
                return (System.String)GetValue("DUNCODE");
            }
            set
            {
                SetValue("DUNCODE", value);
            }
        }

        [Field("GOVERNMENT_CODE", TableAlias = "a")]
        public string GOVERNMENTCODE
        {
            get
            {
                return (System.String)GetValue("GOVERNMENTCODE");
            }
            set
            {
                SetValue("GOVERNMENTCODE", value);
            }
        }

        [Field("DESCRIPTION", TableAlias = "a")]
        public string ProductName
        {
            get
            {
                return (System.String)GetValue("ProductName");
            }
            set
            {
                SetValue("ProductName", value);
            }
        }

        [Field("SHORT_DESCRIPTION", TableAlias = "a")]
        public string ShortProductName
        {
            get
            {
                return (System.String)GetValue("ShortProductName");
            }
            set
            {
                SetValue("ShortProductName", value);
            }
        }

        [Field("CATEGORY_CODE", TableAlias = "a")]
        public string CategoryCode
        {
            get
            {
                return (System.String)GetValue("CategoryCode");
            }
            set
            {
                SetValue("CategoryCode", value);
            }
        }

        [Field("BRAND_CODE", TableAlias = "a")]
        public string BrandCode
        {
            get
            {
                return (System.String)GetValue("BrandCode");
            }
            set
            {
                SetValue("BrandCode", value);
            }
        }

        [Field("FORM_CODE", TableAlias = "a")]
        public string FORMCODE
        {
            get
            {
                return (System.String)GetValue("FORMCODE");
            }
            set
            {
                SetValue("FORMCODE", value);
            }
        }

        [Field("STATISTIC_UNIT", TableAlias = "a")]
        public decimal STATISTICUNIT
        {
            get
            {
                return (System.Decimal)GetValue("STATISTICUNIT");
            }
            set
            {
                SetValue("STATISTICUNIT", value);
            }
        }

        [Field("STACKABILTY_FACTOR", TableAlias = "a")]
        public decimal STACKABILTYFACTOR
        {
            get
            {
                return (System.Decimal)GetValue("STACKABILTYFACTOR");
            }
            set
            {
                SetValue("STACKABILTYFACTOR", value);
            }
        }

        [Field("ADDITIONAL_LVL1", TableAlias = "a")]
        public string ADDITIONALLVL1
        {
            get
            {
                return (System.String)GetValue("ADDITIONALLVL1");
            }
            set
            {
                SetValue("ADDITIONALLVL1", value);
            }
        }

        [Field("ADDITIONAL_LVL2", TableAlias = "a")]
        public string ADDITIONALLVL2
        {
            get
            {
                return (System.String)GetValue("ADDITIONALLVL2");
            }
            set
            {
                SetValue("ADDITIONALLVL2", value);
            }
        }

        [Field("PIECE_PRICE", TableAlias = "a")]
        public decimal PIECE_PRICE
        {
            get
            {
                return (System.Decimal)GetValue("PIECE_PRICE");
            }
            set
            {
                SetValue("PIECE_PRICE", value);
            }
        }

        [Field("MANUFACTURER_CODE", TableAlias = "a")]
        public string ManuCode
        {
            get
            {
                return (System.String)GetValue("ManuCode");
            }
            set
            {
                SetValue("ManuCode", value);
            }
        }

        [Field("TYPE", TableAlias = "a")]
        public decimal TYPE
        {
            get
            {
                return (System.Decimal)GetValue("TYPE");
            }
            set
            {
                SetValue("TYPE", value);
            }
        }

        [Field("BASE_UOM_CODE", TableAlias = "a")]
        public string BASEUOMCODE
        {
            get
            {
                return (System.String)GetValue("BASEUOMCODE");
            }
            set
            {
                SetValue("BASEUOMCODE", value);
            }
        }

        [Field("SKU_TYPE", TableAlias = "a")]
        public string SKUTYPE
        {
            get
            {
                return (System.String)GetValue("SKUTYPE");
            }
            set
            {
                SetValue("SKUTYPE", value);
            }
        }

        [Field("PROMO_FLAG", TableAlias = "a")]
        public string PROMOFLAG
        {
            get
            {
                return (System.String)GetValue("PROMOFLAG");
            }
            set
            {
                SetValue("PROMOFLAG", value);
            }
        }



        [Field("SHIPMENT_START", TableAlias = "a")]
        public System.DateTime SHIPMENTSTART
        {
            get
            {
                return (System.DateTime)GetValue("SHIPMENTSTART");
            }
            set
            {
                SetValue("SHIPMENTSTART", value);
            }
        }

        [Field("SHIPMENT_END", TableAlias = "a")]
        public System.DateTime SHIPMENTEND
        {
            get
            {
                return (System.DateTime)GetValue("SHIPMENTEND");
            }
            set
            {
                SetValue("SHIPMENTEND", value);
            }
        }

        [Field("ADDITIONAL_INFO", TableAlias = "a")]
        public string ADDITIONALINFO
        {
            get
            {
                return (System.String)GetValue("ADDITIONALINFO");
            }
            set
            {
                SetValue("ADDITIONALINFO", value);
            }
        }

        [Field("DISCOUNT_ID", TableAlias = "a")]
        public decimal DISCOUNTID
        {
            get
            {
                return (System.Decimal)GetValue("DISCOUNTID");
            }
            set
            {
                SetValue("DISCOUNTID", value);
            }
        }

        [Field("DOMAIN_ID", TableAlias = "a")]
        public decimal DOMAINID
        {
            get
            {
                return (System.Decimal)GetValue("DOMAINID");
            }
            set
            {
                SetValue("DOMAINID", value);
            }
        }


        [Field("LAST_UPDATER", TableAlias = "a")]
        public string LAST_UPDATER
        {
            get
            {
                return (System.String)GetValue("LAST_UPDATER");
            }
            set
            {
                SetValue("LAST_UPDATER", value);
            }
        }

        [Field("LAST_UPDATE_TIME", TableAlias = "a")]
        public long LAST_UPDATE_TIME
        {
            get
            {
                return (long)GetValue("LAST_UPDATE_TIME", DateTime.Now);
            }
            set
            {
                SetValue("LAST_UPDATE_TIME", value);
            }
        }

        [Field("CREATE_TIME", TableAlias = "a")]
        public long CREATETIME
        {
            get
            {
                return (long)GetValue("CREATETIME", DateTime.Now);
            }
            set
            {
                SetValue("CREATETIME", value);
            }
        }

        [Field("ACTIVE", TableAlias = "a")]
        public Boolean ACTIVE
        {
            get
            {
                return (System.Boolean)GetValue("ACTIVE", false);
            }
            set
            {
                SetValue("ACTIVE", value);
            }
        }
        [Field("TAX_ID", TableAlias = "a")]
        public decimal TAXID
        {
            get
            {
                return decimal.Parse(GetValue("TAXID",0).ToString());
            }
            set
            {
                SetValue("TAXID", value);
            }
        }

        [Field("CASE_PRICE", TableAlias = "a")]
        public decimal CasePrice
        {
            get
            {
                return (System.Decimal)GetValue("CasePrice");
            }
            set
            {
                SetValue("CasePrice", value);
            }
        }



        [Field("START_TIME", TableAlias = "a")]
        public DateTime START_TIME
        {
            get { return (System.DateTime)GetValue("START_TIME"); }
            set { SetValue("START_TIME", value); }
        }

        [Field("END_TIME", TableAlias = "a")]
        public DateTime END_TIME
        {
            get { return (System.DateTime)GetValue("END_TIME"); }
            set { SetValue("END_TIME", value); }
        }

        [Field("ORG_ID", TableAlias = "a")]
        public int ORG_ID
        {
            get { return (System.Int16)GetValue("ORG_ID"); }
            set { SetValue("ORG_ID", value); }
        }

        [CalculateField]
        public string FORMNAME
        {
            get
            {
                FORMS from = (FORMS)ObjectRow.Load(typeof(FORMS),
                    string.Format(" CODE='{0}' AND DOMAIN_ID='{1}'", this.FORMCODE, this.DOMAINID));
                if (from != null)
                    return from.FormName;
                return "";
            }
        }

        [Field("DENOMINATOR", TableAlias = "b")]
        public decimal DENOMINATOR
        {
            get
            {
                return (System.Decimal)GetValue("DENOMINATOR");
            }
            set
            {
                SetValue("DENOMINATOR", value);
            }
        }
    }
}
